package com.data.center.dictionary;

import com.data.center.exception.exception.BizException;
import com.data.center.exception.info.CommonEnum;

/**
 * @author DN
 * @description: 行政级别编码映射枚举类CD000024
 * @date 2023/11/27 10:06
 */
public enum JobLevel implements KeyValueMap {

    CIVIL_SERVANT("1", "公务员职务级别"),
    NATIONAL_PRINCIPAL("101", "国家级正职"),
    NATIONAL_DEPUTY("102", "国家级副职"),
    PROVINCIAL_PRINCIPAL("111", "省部级正职"),
    PROVINCIAL_DEPUTY("112", "省部级副职"),
    DEPARTMENTAL_PRINCIPAL("121", "厅局级正职"),
    DEPARTMENTAL_DEPUTY("122", "厅局级副职"),
    COUNTY_PRINCIPAL("131", "县处级正职"),
    COUNTY_DEPUTY("132", "县处级副职"),
    TOWNSHIP_PRINCIPAL("141", "乡科级正职"),
    TOWNSHIP_DEPUTY("142", "乡科级副职"),
    CLERK("150", "科员级"),
    STAFF_OFFICER("160", "办事员级"),
    UNDEFINED_CIVIL_SERVANT("199", "未定职公务员"),

    STAFF_LEVEL("2", "职员级别"),
    LEVEL_ONE("211", "一级职员"),
    LEVEL_TWO("212", "二级职员"),
    LEVEL_THREE("221", "三级职员"),
    LEVEL_FOUR("222", "四级职员"),
    LEVEL_FIVE("231", "五级职员"),
    LEVEL_SIX("232", "六级职员"),
    LEVEL_SEVEN("241", "七级职员"),
    LEVEL_EIGHT("242", "八级职员"),
    LEVEL_NINE("250", "九级职员"),
    LEVEL_TEN("260", "十级职员"),
    UNDEFINED_LEVEL_STAFF("299", "未定级职员"),

    // 专业技术职务级别
    PROFESSIONAL_AND_TECHNICAL_JOB_LEVELS("4", "专业技术职务级别"),
    SENIOR("410", "高级"),
    SENIOR_PRINCIPAL("411", "正高级"),
    SENIOR_DEPUTY("412", "副高级"),
    INTERMEDIATE("420", "中级"),
    JUNIOR("430", "初级"),
    ASSISTANT("434", "助理级"),
    EMPLOYEE("435", "员级"),
    UNDEFINED_TECHNICAL_LEVEL("499", "未定职级专业技术人员");

    private String code;
    private String name;

    JobLevel(String code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public String getKey() {
        return code;
    }

    @Override
    public String getValue() {
        return name;
    }

    public static JobLevel getValueByKey(String key) {
        for (JobLevel jobLevel : values()) {
            if (jobLevel.code.equals(key)) {
                return jobLevel;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }

    public static JobLevel getKeyByValue(String value) {
        for (JobLevel jobLevel : values()) {
            if (jobLevel.name.equals(value)) {
                return jobLevel;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }
}
